/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package docview;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.JPanel;
import tableprocessor.FileProcessor;
import tableprocessor.Table;

/**
 *
 * @author Dema
 */
public class DocViewManager {
    
    private ViewDoc view;
    private FileProcessor processor;
    private Iterator<Table> tableIterator;
    private PriceListManager manager;
    private File lastOpened;
    public DocViewManager(ViewDoc _view)
    {
        view = _view;
        processor = new FileProcessor();
        manager = new PriceListManager();
    }

    public DocViewManager()
    {
        view = null;
        processor = new FileProcessor();
        manager = new PriceListManager();
    }

    public void openFile(File file)
    {
        lastOpened = file;
        tableIterator = processor.load(file.getAbsolutePath());
    }
    public void createEmptyTable()
    {
        List<Table> tlist = new ArrayList<Table>();
        Table t = new Table();
        t.insertRow(0);
        t.insertData(0, 0, "");
        tlist.add(t);
        tableIterator = tlist.iterator();
    }
    public void createNewView(ViewDoc _view)
    {
        view = _view;
    }

    public JPanel showView()
    {
        return view.viewDocument(tableIterator);
    }

    public boolean isFileOpened()
    {
        if (tableIterator.equals(null))
            return false;
        return true;
    }

    public void addNewVocabulary(Vocabulary _v)
    {
        manager.addPriceVocabulary("1", _v);
    }
    


};
